package com.yunshipei.core.ui.client;

import android.net.Uri;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebView;

public class FaceWebChromeClient extends WebChromeClient {

    private ValueCallback<Uri[]> filePathCallback;
    private FaceWebChromeClientInteractionListener faceWebChromeClientInteractionListener;

    public FaceWebChromeClient(FaceWebChromeClientInteractionListener faceWebChromeClientInteractionListener) {
        this.faceWebChromeClientInteractionListener = faceWebChromeClientInteractionListener;
    }

    @Override
    public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
        this.filePathCallback = filePathCallback;
        return faceWebChromeClientInteractionListener != null && faceWebChromeClientInteractionListener.onShowFileChooser();
    }

    public ValueCallback<Uri[]> getFilePathCallback() {
        return filePathCallback;
    }

    public interface FaceWebChromeClientInteractionListener {
        boolean onShowFileChooser();
    }
}
